﻿<?php 
$cache_time=1;
require_once("include/header.php")?>
<title>Lỗi biên dịch</title>
<div class="body-wrap nobg">
	<div class="wrapper">
		
		
		<div class="main">
			<div class="col-a1"><h3>Lỗi biên dịch</h3>
<?php require_once("./include/db_info.inc.php");
require_once("./include/const.inc.php");
if (!isset($_GET['sid'])){
	echo "Không có mã nguồn!\n";
	require_once("include/footer.php");
	exit(0);
}
$ok=true;
$id=strval(intval($_GET['sid']));
$sql="SELECT * FROM `solution` WHERE `solution_id`='".$id."'";
$result=mysql_query($sql);
$row=mysql_fetch_object($result);
if ($row && $row->user_id==$_SESSION['user_id']) $ok=true;
if (($_SESSION['user_rights']{0}=="B")) $ok=true;
if ($ok==true){
	if($row->user_id!=$_SESSION['user_id'])
		echo "<a href='mail.php?to_user=$row->user_id&title=$MSG_SUBMIT $id'>Gửi tác giả</a>";
	echo "<font color='red'><pre>";
	mysql_free_result($result);
	$sql="SELECT `error` FROM `compileinfo` WHERE `solution_id`='".$id."'";
	$result=mysql_query($sql);
	$row=mysql_fetch_object($result);
	echo htmlspecialchars(str_replace("\n\r","\n",$row->error))."</pre></font>";
	mysql_free_result($result);
	echo "Mã nguồn:<br>";
	$sql="SELECT * FROM `source_code` WHERE `solution_id`='".$id."'";
	$result=mysql_query($sql) or die ("error2");
	$row=mysql_fetch_object($result);
	if ($row) 
	{
		echo "<pre><font face='Courier New' color='blue'>";
		echo str_replace("  ","&nbsp; ",str_replace("\r\n","<br>",htmlspecialchars($row->source)));
		echo "</font></pre>";
	}
	
}else{
	mysql_free_result($result);
	echo "Bạn không thể xem !";
}
echo "<br><a href='#' onclick='history.go(-1);'>Quay lại</a>";
?>
			</div>
			<div class="col-b4 qcao">
					<?php include("qcao.php");?>
			</div>
			<div class="clear"></div>
		</div>
	</div>
</div>
<?php
require_once("include/footer.php")
?>
